<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head >
    <title>搜索管理后台 - 热门词库管理</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="${request.contextPath}/css/style_manager.css">
	<script type="text/javascript" src="${request.contextPath}/js/jquery-1.4.2.js"></script>
	<script type="text/javascript" src="${request.contextPath}/js/manager.js"></script>
	<script type="text/javascript" src="${request.contextPath}/js/my97/WdatePicker.js"></script>
	<script type="text/javascript" src="${request.contextPath}/js/jquery.overblock-1.2.js"></script>
		
	<script type="text/javascript">
	var list = null;
	$(function(){
		
		list = new IndListObject('listhot', 'dataDiv', 'pageNumDiv');
		list.pp = 15;
		list.init();
		list.list(1, function(){
			initEvent();
		});
	});
	
	function IndListObject(url, listId, pageNumId){
		ListObject.call(this, url, listId, pageNumId);
	}
	/**
	* 通过原型方法，继承了父类的function
	*/
	IndListObject.prototype = new ListObject();
	IndListObject.prototype.success = function(json) {
		var h = '';
		if(json !== null && json.length > 4){
			var obj1 = eval(json)[0];
			this.total = obj1.count;
			var list = obj1.list;
			h = '<table id="listTable" border="0" >' +
				'	<tr>' +
				'		<td class="center title" width="45"><span id="selectAll">选择</span></td>' +
				'		<td class="title sort" onclick="sortData(\'keyWord\');">关键字</td>' +
				'		<td class="title sort" width="100" onclick="sortData(\'sort\');">排序</td>' +
				'		<td class="center title" style="min-width:50px;">类别</td>' +
				'		<td class="center title sort" onclick="sortData(\'searchCount\');" style="">搜索次数</td>' +
				'		<td class="center title sort" onclick="sortData(\'rsCount\');" style="">搜索结果数</td>' +
				'		<td width="140" class="center title sort" onclick="sortData(\'addTime\');">添加时间</td>' +
				'		<td width="70" class="center title">操作</td>' +
				'	</tr>';
			for(var i = 0, len = list.length; i < len; i ++){
				var o = list[i];
				var kid = o.id;
				var kw = o.keyWord || [];
				var cn = o.cate && o.cate.name || '';
				var atime = o.addTimeStr || '';
				var searchC = o.searchCount || 0;
				var rsC = o.rsCount || 0;
				var whtml = kw;
				var sort = o.sort;
				
				h +='	<tr class="bgTr">' +
					'		<td class="center"><input type="checkbox" class="checkBoxes" value='+kid+' /></td>' +
					'		<td class="moreOptTd">'+whtml+'</td>' +
					'		<td class="center"><input type="hidden" class="sortOld" value="'+sort+'" /><input onkeyup="onChangeSort(this)" class="sortNew" type="text" size="4" value="'+sort+'" /><a class="saveSort" href="javascript:void(0)" onclick="saveSort(this);">保存</a></td>' +
					'		<td class="center" style="white-space:nowrap;">'+cn+'</td>' +
					'		<td class="center" style="white-space:nowrap;">'+searchC+'</td>' +
					'		<td class="center" style="white-space:nowrap;">'+rsC+'</td>' +
					'		<td class="center" style="white-space:nowrap;">'+atime+'</td>' +
					'		<td class="center" style="white-space:nowrap;">' +
					'			<a href="javascript:void(0);" onclick="batchDelete(\''+kid+'\');" class="aDelete">删除</a>' +
					'		</td>' +
					'	</tr>';
			}
			if(list.length < 1){
				h += '<tr><td colspan="8">'+noDataMessage+'</td></tr>';
			}
			h += '</table>';
			$('#'+this.listId).html(h);
		}else{
			h = noDataMessage;
			alert(1);
			$('#'+this.listId).html(h);
		}
	};
	IndListObject.prototype.setParams = function() {
		this.paramObj.cp = this.cp;
		this.paramObj.pp = this.pp;
		
		this.paramObj.keyword = v('#keyword');
		this.paramObj.beginTime = v('#bdate');
		this.paramObj.endTime = v('#edate');
		this.paramObj.sort = v('#sortInput');
		this.paramObj.cateId = v('#allCateSelect');
	};
	
	function initEvent(){
		$('#addCate').click(function(){
			$('#addCateInfo').showPop({'blockStyle':{color:'#dddddd'}, 'closeable':false, 'fadeTime':300});
		});
		$('#closeCate').click(function(){
			$('#addCateInfo').hidePop(300);
		});
	}
	
	function ListData(n, func){
		list.list(n, func);
	}
	var sortType = 1;
	function sortData(f){
		var s = f || '';
		s = (sortType > 0 ? '' : '-') + s;
		sortType = sortType * -1;
		$('#sortInput').val(s);
		ListData(1)
	}
		
	function reset(){
		$('#bdate,#edate,#keyword,#sortInput').val('');
		$("#allCateSelect option:eq(0)").attr('selected', 'selected');
		ListData(1)
	}
	
	//删除
	function batchDelete(id){
		id = id || getids();
		if(id == null || id.length < 1){
			return;
		}
		if(!confirm('是否删除？')){
			return;
		}
		ajax('deletehot?ids=' + id, function(rs){
			if(rs == 1){
				s = '删除成功！';
			}else{
				s = '删除失败！';
			}
			showRs(s);
			ListData()
		});
	}
	
	function doBatchCate(){
		var ids = getids();
		if(ids == null || ids.length < 1){
			return;
		}
		var cateid = $('#cateInfoHTML #allCateSelect').val();
		ajax('batchCateHot?ids='+ids+'&cateid='+cateid, function(rs){
			reloadPage();
		});
	}
	
	function onChangeSort(obj) {
		var td = $(obj).parent('td');
		var ns = $(obj).val();
		var os = td.find('input.sortOld').val();
		
		if(ns != os){
			td.find('a.saveSort').fadeIn(0);
		}else{
			td.find('a.saveSort').fadeOut(0);
		}
	}
	function saveSort(obj){
		var tr = $(obj).parents('.bgTr');
		var id = tr.find('.checkBoxes').val();
		var v = tr.find('input.sortNew').val();
		ajax('updateHot?ids='+id + '&vals='+v, function(rs){
			reloadPage();
		});
	}
	</script>
	<style type="text/css">
	input.inputBox{
		border-radius:4px;
		border:1px solid #aaaaaa;
		height:23px;
		padding-left:5px;
	}
	.saveSort{
		display:none;
		font-size:13px;
	}
	</style>
  </head>
  <body>
  	<div id="containerDiv">
  		<div style="">
			<h3>热门词库管理</h2>
  		</div>
  		<div style="font-size:13px;padding:5p;margin-bottom:20px;">
			日期：从
			<input type="text" class="inputBox" value="" readOnly="readOnly" onclick="WdatePicker({el:'bdate',dateFmt:'yyyy-MM-dd HH:mm:ss'});" id="bdate" size="16" />
			到
			<input type="text" class="inputBox" value="" readOnly="readOnly" id="edate" size="16" onclick="WdatePicker({el:'edate',dateFmt:'yyyy-MM-dd HH:mm:ss'});" />
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;类别：
			<select style="border-radius:4px;height:23px;" id="allCateSelect">
				<option value="">全部</option>
			</select>
			<span id="addCate" class="addBtn">+</span>
			
			<div style="margin-top:5px;">
				关键字：&nbsp;<input type="text" class="inputBox" id="keyword" value="" size="50" />&nbsp;&nbsp;
				<input type="button" value="搜索" class="btnStyle1" onclick="ListData(1);" />&nbsp;&nbsp;
				<input type="button" value="重置" style="background-color:red;" class="btnStyle1"  onclick="reset();" />
				<input type="button" value="刷新" class="btnStyle1" onclick="reloadPage();" />
				&nbsp;&nbsp;&nbsp;&nbsp;
			  	<input type="button" style="float:right;margin-right:120px;" value="热门词导入" class="btnStyle1" id="importBtn" />
			  	<input type="hidden" id="sortInput" value="" />
			</div>
  		</div>
  		<div>
  		</div>
	  	<div id="dataDiv">
	  		
	  	</div>
	  	<div id="pageNumDiv">
	  		
	  	</div>
			<input type="button" value="删除所选" id="batchDel" onclick="batchDelete();" class="btnStyle1" />
		  	<input type="button" value="指定类别" id="batchCate" onclick="batchCate();" class="btnStyle1" />
		  	<span id="batchResult" style="color:red;font-weight:bold;margin-left:230px;">&nbsp;</span>
  	</div>
  	
  	
  	<input type="hidden" value="添加热门词库类别" id="cateTitleInput" />
  	<input type="hidden" value="hot_word" id="CATEINFOTYPE" />
  	<#include "./cate_float.ftl" />
  	<#include "./same_word.ftl" />
  	<#include "./upload_temp.ftl" />
  	
  	
  </body>
</html>
